package com.classicInterview;

/**
 * @Author: huangzhigao
 * @Date: 2023/5/7 16:56
 */
public class Code27 {
    public static int removeElement(int[] nums, int val) {
        int index = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val) {
                nums[index++] = nums[i];
            }
        }
        return index;
    }

    public static void main(String[] args) {
        int[] nums = {1,2,3,4,2};
        System.out.println(removeElement(nums,2));
        System.out.println(nums);
    }
}
